package org.cool.vnc.proto;

import org.jboss.netty.buffer.ChannelBuffer;

public enum SecurityType {
	INVALID(0), None(1), VNC_AUTH(2), RA2(5), RA2ne(6), Tight(16), Ultra(17), TLS(
			18), VeNCrypt(19), GTK_VNC_SASL(20), MD5_HASH(21), ColinDean_xvp(22);

	public final int ID;

	private SecurityType(int id) {
		this.ID = id;
	}

	public void write(ChannelBuffer buf) {
		buf.writeByte(this.ordinal());
	}

	public static SecurityType[] parse(ChannelBuffer buf) {
		SecurityType[] types = new SecurityType[buf.readUnsignedByte()];
		SecurityType[] available = SecurityType.values();
		for (int i = 0; i < types.length; i++) {
			types[0] = available[buf.readUnsignedByte()];
		}
		return types;
	}

}
